<?php
use App\User;
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
	$api->post('/bind', 'App\Api\Controllers\WechatTestController@testinfo');
	$api->any('/notify','App\Api\GoModule\Controllers\PayController@notify');
        $api->any('/send/notify', 'App\Api\SendModule\Controllers\SendPayController@notify');
    $api->group(['namespace' => 'App\Api\Controllers'], function ($api) {
        $api->get('test', 'LoginController@test');
        $api->get('/login', 'LoginController@index');
        $api->get('/sms', 'LoginController@message');
        $api->get('/toke', 'AuthController@authenticate');
        $api->get('/code', 'LoginController@code');
	    $api->get('/config','LoginController@jsConfig');       
        $api->group(['middleware' => 'apiweb'], function ($api) {

            $api->group(['middleware' => 'jwt.api.auth'], function ($api) {
                $api->post('/check', 'LoginController@check');
                $api->post('/sess', 'LoginController@sessionSet');
                $api->group(['middleware' => 'checkphone'], function ($api) {
                    $api->get('/addrecord', 'OrderController@addRecord');
                    
                   // $api->group(['middleware' => 'finishOrder'], function ($api) {
		        $api->post('/setstar', 'OrderController@orderStar');
                   // });
		    
		    $api->post('/back', 'OrderController@orderBack');
                    $api->get('/recordlist', 'OrderController@orderRecordList');
			$api->get('/deliveryrecordlist', 'OrderController@deliveryRecordList');
                    $api->get('/recordone', 'OrderController@orderRecordOne');
                    $api->get('/logout', 'AuthController@logout');
                    $api->get('/test', 'LoginController@test');
                });
            });
        });
    });

    //Go module
    $api->group(['namespace' => 'App\Api\GoModule\Controllers'], function ($api) {

        $api->group(['middleware' => 'apiweb'], function ($api) {
                 $api->post('/user/carNum', 'UserPostController@carNum');
                 $api->post('/user/price', 'UserPostController@price');
            $api->group(['middleware' => 'jwt.api.auth'], function ($api) {
		
                 $api->post('/user/sendCode', 'UserChangeInfoController@sessionSet');
                 $api->post('/user/changePhone', 'UserChangeInfoController@changePhone');
                 $api->group(['middleware' => 'checkphone'], function ($api) {
                    	
                   // $api->group(['middleware' => 'noWaitPay'], function ($api) {  //有未付款订单的话，不能通过此中间件
			         $api->post('/userCheckOrder', 'GoController@userCheckOrder');
                    	$api->post('/checkOrderStatus', 'GoController@checkOrderStatus');
                    	$api->post('/checkDriverLocation', 'GoController@checkDriverLocation');
                   // $api->group(['middleware' => 'beforeOrder'], function ($api) {
                    	$api->post('/user/orderSave', 'UserPostController@orderSave');
                   // });
		    
                    	$api->post('/user/getInfo', 'UserChangeInfoController@getInfo');
                    	$api->post('/user/changeInfo', 'UserChangeInfoController@changeInfo');
                        $api->post('/user/sendCode', 'UserChangeInfoController@sessionSet');
                        $api->post('/user/changePhone', 'UserChangeInfoController@changePhone');
                 
		    	//$api->post('/user/sendCodeUnbind', 'UserChangeInfoController@sendCodeToUnBind');  //发送短信解除手机绑定
                    	//$api->post('/user/unBindPhone', 'UserChangeInfoController@unBindPhone');
                   // });
	       	   
		              $api->post('/pay', 'PayController@unifiedOrder');
                              $api->post('/enterprisePay', 'EnterprisePayController@send');
                 });
            });
        });
    });
    //send module
    $api->group(['namespace' => 'App\Api\SendModule\Controllers'], function ($api) {
        $api->group(['middleware' => 'apiweb'], function ($api) {
                    $api->post('/user/send/carNum', 'SendController@carNum');
                    $api->post('/user/send/price', 'SendController@price');
            $api->group(['middleware' => 'jwt.api.auth'], function ($api) {
                  $api->group(['middleware' => 'checkphone'], function ($api) {
	            $api->post('/send/pay', 'SendPayController@unifiedOrder');
                    $api->post('/user/send/orderPush', 'SendController@orderPush');
		    $api->post('/send/userCheckOrder', 'SendController@userCheckOrder');
		    $api->post('/send/checkDeliOrderStatus', 'SendController@checkOrderStatus');
                  });
            });
        });
    });


//driver
    $api->group(['middleware' =>'web','prefix'=>'Driver'], function ($api) {

        $api->get('start', 'driver\CommonController@start');
        $api->get('end', 'driver\CommonController@end');
        $api->get('pushOrder', 'driver\CommonController@pushOrder');
        $api->get('getOrder', 'driver\CommonController@getOrder');
        $api->get('finishOrder', 'driver\CommonController@finishOrder');
    });
});
